package com.ruoyi.zhgd.controller;

import java.util.List;

import com.ruoyi.zhgd.domain.NLaboratoryAsphaltRequires;
import com.ruoyi.zhgd.dto.AsphaltRequiresDto;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;

import cn.dev33.satoken.annotation.SaCheckLogin;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zhgd.domain.vo.NLaboratoryAsphaltRequiresVo;
import com.ruoyi.zhgd.domain.bo.NLaboratoryAsphaltRequiresBo;
import com.ruoyi.zhgd.service.INLaboratoryAsphaltRequiresService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 沥青技术要求详情
 *
 * @author cj
 * @date 2023-09-21
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/zhgd/laboratoryAsphaltRequires")
public class NLaboratoryAsphaltRequiresController extends BaseController {

    private final INLaboratoryAsphaltRequiresService iNLaboratoryAsphaltRequiresService;

    /**
     * 查询沥青技术要求详情列表
     */
    @SaCheckLogin
    @GetMapping("/list")
    public TableDataInfo<NLaboratoryAsphaltRequiresVo> list(NLaboratoryAsphaltRequiresBo bo, PageQuery pageQuery) {
        return iNLaboratoryAsphaltRequiresService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出沥青技术要求详情列表
     */
    @SaCheckLogin
    @Log(title = "沥青技术要求详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(NLaboratoryAsphaltRequiresBo bo, HttpServletResponse response) {
        List<NLaboratoryAsphaltRequiresVo> list = iNLaboratoryAsphaltRequiresService.queryList(bo);
        ExcelUtil.exportExcel(list, "沥青技术要求详情", NLaboratoryAsphaltRequiresVo.class, response);
    }

    /**
     * 获取沥青技术要求详情详细信息
     *
     * @param id 主键
     */
    @SaCheckLogin
    @GetMapping("/{id}")
    public R<AsphaltRequiresDto> getInfo(@PathVariable String id) {
        return R.ok(iNLaboratoryAsphaltRequiresService.queryById(id));
    }

    /**
     * 新增沥青技术要求详情
     */
   /* @SaCheckLogin
    @Log(title = "沥青技术要求详情", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody NLaboratoryAsphaltRequiresBo bo) {
        return toAjax(iNLaboratoryAsphaltRequiresService.insertByBo(bo));
    }*/

   /**
   * 沥青类技术要求新增
   * @author cj
   * @date 2023/9/22 9:33
   * @return
   **/
    @SaCheckLogin
    @Log(title = "沥青技术要求_列表", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R saveRequires(@RequestBody AsphaltRequiresDto dto) {

        iNLaboratoryAsphaltRequiresService.saveRequires(dto);
        return R.ok();
    }

/*
    *//**
     * 修改沥青技术要求详情
     *//*
    @SaCheckLogin
    @Log(title = "沥青技术要求详情", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody NLaboratoryAsphaltRequiresBo bo) {
        return toAjax(iNLaboratoryAsphaltRequiresService.updateByBo(bo));
    }*/
    /**
     * @Title: page
     * @Description: 沥青类技术要求修改
     * @param dto 查询条件
     * @return Result 沥青类技术要求修改
     */
    @PostMapping("/edit")
    public R<String> edit(@RequestBody AsphaltRequiresDto dto) {
        iNLaboratoryAsphaltRequiresService.updateRequires(dto);
        return R.ok();
    }

  /*  *//**
     * 删除沥青技术要求详情
     *
     * @param  主键串
     *//*
    @SaCheckLogin
    @Log(title = "沥青技术要求详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable String[] ids) {
        return toAjax(iNLaboratoryAsphaltRequiresService.deleteWithValidByIds(Arrays.asList(ids), true));
    }*/
    /**
     * @Title: page
     * @Description: 沥青类技术要求删除
     * @param id 查询条件
     * @return Result 沥青类技术要求删除
     */
    @DeleteMapping("/{id}")
    public R<String> remove(@PathVariable("id") String id) {
        iNLaboratoryAsphaltRequiresService.removeRequires(id);
        return R.ok("操作成功！");
    }

    /**
    * 样品绑定技术下拉
    * @author cj
    * @date 2023/10/23 17:04
    * @return
    **/
    @SaCheckLogin
    @GetMapping("/selectList")
    public R selectList(@RequestParam String type) {
        List<NLaboratoryAsphaltRequires> list = iNLaboratoryAsphaltRequiresService.selectList(type);
        return R.ok(list);
    }

}
